package com.TeacherInfoServer.mapper;

import com.TeacherInfoServer.pojo.DTO.SearchDTO.DoctoralSupervisorSearchDTO;
import com.TeacherInfoServer.pojo.entity.DoctoralSupervisor;
import com.TeacherInfoServer.pojo.vo.DoctoralSupervisorVo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface DoctoralSupervisorMapper extends BaseMapper<DoctoralSupervisor> {
    List<DoctoralSupervisor> selectPageWithTeacher(Page<DoctoralSupervisor> page);



    @Select("<script>" +
            "SELECT ds.*, t.teacher_name " +
            "FROM doctoral_supervisor ds " +
            "LEFT JOIN teacher t ON ds.teacher_id = t.teacher_id " +
            "<where> " +
            "<if test='params.teacherId != null and params.teacherId != \"\"'> " +
            "AND ds.teacher_id LIKE CONCAT('%', #{params.teacherId}, '%') " +
            "</if> " +
            "<if test='params.teacherName != null and params.teacherName != \"\"'> " +
            "AND t.teacher_name LIKE CONCAT('%', #{params.teacherName}, '%') " +
            "</if> " +
            "<if test='params.obtainDate != null and params.obtainDate != \"\"'> " +
            "AND ds.obtain_date LIKE CONCAT('%', #{params.obtainDate}, '%') " +
            "</if> " +
            "<if test='params.obtainSchool != null and params.obtainSchool != \"\"'> " +
            "AND ds.obtain_school LIKE CONCAT('%', #{params.obtainSchool}, '%') " +
            "</if> " +
            "</where>" +
            "</script>")
    Page<DoctoralSupervisorVo> searchDoctorSupervisorList(Page<?> page,@Param("params") DoctoralSupervisorSearchDTO params);





}
